// --------------------------------------------------------------------------------------------------------------------
// <copyright file="201204011946287_V3.cs" company="ecblog.codeplex.com">
//   emrecoskun.net - ibrahimatay.com
// </copyright>
// <summary>
//   Db updates
// </summary>
// --------------------------------------------------------------------------------------------------------------------
 
namespace EcBlog.Migrations
{
    using System.Data.Entity.Migrations;

    using EcBlog.Data.Sql;
    using EcBlog.Extensions;

    /// <summary>
    /// Db updates
    /// </summary>
    public partial class V3 : DbMigration
    {
        /// <summary>
        /// Operations to be performed during the upgrade process.
        /// </summary>
        public override void Up()
        {
            var context = new EcModelContext();
            if (context.IsTableExists("OpenIds"))
            {
                this.AlterColumn("Users", "Username", c => c.String(nullable: false, maxLength: 50));
                this.AlterColumn("SiteSettings", "SettingKey", c => c.String(maxLength: 50));
                this.AlterColumn("SiteSettings", "SettingValue", c => c.String(maxLength: 1000));
                this.AlterColumn("CommentHistories", "Operation", c => c.String(maxLength: 10));
                this.AlterColumn("LayoutHistories", "LayoutPath", c => c.String(nullable: false, maxLength: 100));
                this.AlterColumn("LayoutHistories", "Name", c => c.String(nullable: false, maxLength: 100));
                this.AlterColumn("LayoutHistories", "Operation", c => c.String(maxLength: 10));
                this.AlterColumn("TagHistories", "Operation", c => c.String(maxLength: 10));
                this.AlterColumn("UserHistories", "Username", c => c.String(nullable: false, maxLength: 50));
                this.AlterColumn("UserHistories", "Operation", c => c.String(maxLength: 10));
                this.AlterColumn("PageHistories", "Title", c => c.String(nullable: false, maxLength: 500));
                this.AlterColumn("PageHistories", "Slug", c => c.String(nullable: false, maxLength: 500));
                this.AlterColumn("PageHistories", "Operation", c => c.String(maxLength: 10));
                this.AlterColumn("SiteSettingHistories", "SettingKey", c => c.String(maxLength: 50));
                this.AlterColumn("SiteSettingHistories", "SettingValue", c => c.String(maxLength: 1000));
                this.AlterColumn("SiteSettingHistories", "Operation", c => c.String(maxLength: 10));
            }
        }

        /// <summary>
        /// Operations to be performed during the downgrade process.
        /// </summary>
        public override void Down()
        {
            this.AlterColumn("SiteSettingHistories", "Operation", c => c.String());
            this.AlterColumn("SiteSettingHistories", "SettingValue", c => c.String());
            this.AlterColumn("SiteSettingHistories", "SettingKey", c => c.String());
            this.AlterColumn("PageHistories", "Operation", c => c.String());
            this.AlterColumn("PageHistories", "Slug", c => c.String(nullable: false));
            this.AlterColumn("PageHistories", "Title", c => c.String(nullable: false, maxLength: 200));
            this.AlterColumn("UserHistories", "Operation", c => c.String());
            this.AlterColumn("UserHistories", "PortalRole", c => c.String());
            this.AlterColumn("UserHistories", "Username", c => c.String(nullable: false));
            this.AlterColumn("TagHistories", "Operation", c => c.String());
            this.AlterColumn("LayoutHistories", "Operation", c => c.String());
            this.AlterColumn("LayoutHistories", "Name", c => c.String(nullable: false));
            this.AlterColumn("LayoutHistories", "LayoutPath", c => c.String(nullable: false));
            this.AlterColumn("CommentHistories", "Operation", c => c.String());
            this.AlterColumn("SiteSettings", "SettingValue", c => c.String());
            this.AlterColumn("SiteSettings", "SettingKey", c => c.String()); 
            this.AlterColumn("Users", "PortalRole", c => c.String());
            this.AlterColumn("Users", "Username", c => c.String(nullable: false)); 
        }
    }
}
